<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // Object.prototype[Symbol.iterator] = function() {
        //     const keys = Object.keys(this)
        //     let index = 0;
        //     return {
        //         next: ()=> {
        //             return {
        //                 value: this[keys[index++]],
        //                 done: index > keys.length
        //             }
        //         }
        //     }
        // }

        Object.prototype[Symbol.iterator] = function* iterEntries() {
            let keys = Object.keys(this);
            for (let i = 0; i < keys.length; i++) {
                let key = keys[i];
                yield [key, obj[key]];
            }
        }

        var obj = {
            name: "66"
        }

        for(let key of obj) {
            console.log(key)
        }
    </script>
</body>
</html>